<template>
	<div>
		<h1>root页面</h1>
		title<el-input v-model="data.title"></el-input> <br>		
		price<el-input v-model="data.price"></el-input> <br>	
		img<input type="file" @change="change"/><br>
		<button @click="submit">提交</button>	
	</div>	
</template>

<script setup>
	import {reactive,getCurrentInstance} from "vue"
	let {proxy:{axios}}=getCurrentInstance()
	let data=reactive({
		title:"123",
		price:23,
		img:""
	})
	let change=(e)=>{
		data.img=e.target.files[0]
	}
	let submit=async()=>{
		// console.log(data.img)
		let fdata=new FormData()
		for(let key in data){
			fdata.append(key,data[key])
		}
		let res=await axios.post("/api/addgoods",fdata)
		if(res.data.code==26){
			alert(res.data.info)
		}
		console.log(res)
	}
	
</script>

<style>
</style>